<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Cadastro de categorias</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    </h:head>
    <h:body>
        <ui:composition template="./templates/TemplatePagina.xhtml">
            <ui:define name="barraTitulo">

            </ui:define>
            <ui:define name="barraMenu">

            </ui:define>



            <ui:define name="conteudo">
                <h:form>
                    <p:panel header="Nova Categoria">
                        <h:panelGrid columns="2">
                            <h:outputLabel value="Nome da Categoria: "/>
                            <h:inputText value="#{categoriaController.selecionado.nome}"/>
                            <h:commandButton value="Cadastrar" action="#{categoriaController.adicionar}"/>
                        </h:panelGrid>
                    </p:panel>

                    <p:panel header="Categorias">


                        <p:dataTable value="#{categoriaController.itens}" var="item" editable="true">
                            <p:column headerText="Código">
                                <h:outputText value="#{item.id}"/>
                            </p:column>
                            <p:column headerText="Nome">
                                <h:outputText value="#{item.nome}"/>
                            </p:column>

                            <p:column headerText="&nbsp;">
                                <h:commandLink action="#{categoriaController.prepararEdicao}">
                                    <h:graphicImage library="img" name="editar.png"/>
                                </h:commandLink>

                                <h:outputText value=" "/>
                                <h:outputText value=" "/>
                                <h:commandLink action="#{categoriaController.remover}">
                                    <h:graphicImage library="img" name="remover.png"/>
                                </h:commandLink>
                            </p:column>

                        </p:dataTable>
                    </p:panel>
                </h:form>
            </ui:define>

            <ui:define name="rodape">

            </ui:define>
        </ui:composition>
    </h:body>
</html>

